/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package servletKontrol;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author DELL
 */
@WebServlet(name = "kontrol_adminUtama", urlPatterns = {"/kontrol_adminUtama"})
public class kontrol_adminUtama extends HttpServlet {

    /**
     * Processes requests for both HTTP
     * <code>GET</code> and
     * <code>POST</code> methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        String pilihan = request.getParameter("adminutama");

        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();

//        bean.DataBaseConnection conn = new bean.DataBaseConnection();

        out.println("<html>");

        // head section of document
        out.println("<head>");
        out.println(
                "<title>Proses Data</title>");
        out.println("</head>");

        // body section of document
        out.println("<body>");
        out.println("<table width=\"50%\" align=\"center\" cellspacing=\"0\" cellpadding=\"4px\">");
        out.println("<tr>");
        out.println("<td colspan=\"0\" align=\"center\" width=\"500px\" height=\"500px\">");
        out.println("</b>\n" + "</font>\n" + "</p>");
        out.println("<font face=\"Times New Roman\">");
        out.println("<table border=\"0\" cellpadding=\"5\" bordercolor=\"black\">");       
        out.println("<tr>");
        out.println("<td>\n" + "<font size=\"3\" color=\"#26900A\">" + "<b>");
        if (pilihan.equals("view")) {
            RequestDispatcher rd = request.getRequestDispatcher("/adminFormView.jsp");
            rd.forward(request, response);
        } else if (pilihan.equals("insert")) {
            RequestDispatcher rd = request.getRequestDispatcher("/adminFormInsert.jsp");
            rd.forward(request, response);
        } 

        out.println("</b>\n" + "</font>\n" + "</td>");
        out.println("</tr>");
        out.println("</table>");
        out.println("<p align=\"center\">\n" + "<a href=\"Menu.jsp\">\n" + "<< Kembali");
        out.println("</a>\n" + "</p>");
        out.println("</font>");
        out.println("</td>");
        out.println("</tr>");
        out.println("</table>");
        out.println("</body>");

        // end HTML document
        out.println("</html>");
        out.close();  // close stream to complete the page
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /**
     * Handles the HTTP
     * <code>GET</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Handles the HTTP
     * <code>POST</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>
}
